with v8.Class_Integer, v8.Class_Value, v8.Class_String;
with v8.Class_Script_Data, v8.Class_Script_Origin;
package v8.Class_Script is
   type Script (<>) is tagged limited private;
   type Pointer is access all Script;
   -- A compiled JavaScript script.


   function Create
     (source      : v8.Class_String.Pointer; -- Handle<String>
      origin      : access v8.Class_Script_Origin.Script_Origin := null;
      pre_data    : v8.Class_Script_Data.Pointer := null;
      script_data : v8.Class_String.Pointer := null
     ) return Pointer;  -- Local<Script>
   -- Compiles the specified script (context-independent).
   --
   -- \param source Script source code.
   -- \param origin Script origin, owned by caller, no references are kept
   --   when New() returns
   -- \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile()
   --   using pre_data speeds compilation if it's done multiple times.
   --   Owned by caller, no references are kept when New() returns.
   -- \param script_data Arbitrary data associated with script. Using
   --   this has same effect as calling SetData(), but allows data to be
   --   available to compile event handlers.
   -- \return Compiled script object (context independent; when run it
   --   will use the currently entered context).


   function Create
     (source    : v8.Class_String.Pointer; -- Handle<String>
      filename  : v8.Class_Value.Pointer -- Handle<Value>
     ) return Pointer;  -- Local<Script>
   -- Compiles the specified script using the specified file name
   -- object (typically a string) as the script's origin.
   --
   -- \param source Script source code.
   -- \param file_name file name object (typically a string) to be used
   --   as the script's origin.
   -- \return Compiled script object (context independent; when run it
   --   will use the currently entered context).


   function Compile
     (source      : v8.Class_String.Pointer; -- Handle<String>
      origin      : access v8.Class_Script_Origin.Script_Origin := null;
      pre_data    : v8.Class_Script_Data.Pointer := null;
      script_data : v8.Class_String.Pointer := null
     ) return Pointer;  -- Local<Script>
   -- Compiles the specified script (bound to current context).
   --
   -- \param source Script source code.
   -- \param origin Script origin, owned by caller, no references are kept
   --   when Compile() returns
   -- \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile()
   --   using pre_data speeds compilation if it's done multiple times.
   --   Owned by caller, no references are kept when Compile() returns.
   -- \param script_data Arbitrary data associated with script. Using
   --   this has same effect as calling SetData(), but makes data available
   --   earlier (i.e. to compile event handlers).
   -- \return Compiled script object, bound to the context that was active
   --   when this function was called.  When run it will always use this
   --   context.

   function Compile
     (source      : v8.Class_String.Pointer; -- Handle<String>
      filename    : v8.Class_Value.Pointer; -- Handle<Value>
      script_data : v8.Class_String.Pointer := null
     ) return Pointer; -- Local<Script>
   -- Compiles the specified script using the specified file name
   -- object (typically a string) as the script's origin.
   --
   -- \param source Script source code.
   -- \param file_name File name to use as script's origin
   -- \param script_data Arbitrary data associated with script. Using
   --   this has same effect as calling SetData(), but makes data available
   --   earlier (i.e. to compile event handlers).
   -- \return Compiled script object, bound to the context that was active
   --   when this function was called.  When run it will always use this
   --   context.


   function Run
     (this : in out Script
     ) return v8.Class_Value.Pointer;  -- Local<Value>
   -- Runs the script returning the resulting value.  If the script is
   -- context independent (created using ::Create) it will be run in the
   -- currently entered context.  If it is context specific (created
   -- using ::Compile) it will be run in the context in which it was
   -- compiled.


   function Id
     (this : in out Script
     ) return v8.Class_Value.Pointer;  -- Local<Value>
   -- Returns the script id value.


   procedure Set_Data
     (this : in out Script;
      data : v8.Class_String.Pointer);  -- Handle<String>
   -- Associate an additional data object with the script. This is mainly used
   -- with the debugger as this data object is only available through the
   -- debugger API.


private
   type Script is tagged limited null record;


   pragma Import (CPP, Run, "_ZN2v86Script3RunEv");
   pragma Import (CPP, Id, "_ZN2v86Script2IdEv");
   pragma Import (CPP, Set_Data, "_ZN2v86Script7SetDataENS_6HandleINS_6StringEEE");
end v8.Class_Script;
